/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package GUI_SIFACT;

import AccesoDatosAvanzado.AD_Empleado;
import AccesoDatosAvanzado.AD_Empleado_Users;
import AccesoDatosSimple.cEmpleado;
import AccesoDatosSimple.cEmpleado_Users;
import GUI_Busquedas.Frm_busq_empleado;
//import GUI_Busquedas.Frm_busq_Empleado;
import java.util.logging.Level;
import java.util.logging.Logger;
import javax.swing.JOptionPane;
import sifact.conexion.cConexion;

/**
 *
 * @author Cyber Huevadictos
 */
public class Frm_Empleado extends javax.swing.JFrame {

    private String txtnulos = "Los Campos Vacios son:\n";

    /**
     * Creates new form Frm_Empleado
     */
    public Frm_Empleado() {
        setDefaultLookAndFeelDecorated(true);
        this.addFocusListener(null);
        initComponents();
    }
//funcion para limpiar los campos

    private void CamposClean() {
        jTextFieldCodigo.setText(null);
        jTextFieldCedula.setText(null);
        jTextFieldNombres.setText(null);
        jTextFieldApellidos.setText(null);
        jTextFieldTlfno1.setText(null);
        jTextFieldTlfno2.setText(null);
        jTextAreaDireccion.setText(null);
        jTextFieldUsuario.setText(null);
        jPasswordFieldPassword.setText(null);
    }
//funcion para bloquear campos cuando es Insercion

    private void CamposInsert() {
        //texto
        jTextFieldCedula.setEnabled(true);
        jTextFieldNombres.setEnabled(true);
        jTextFieldApellidos.setEnabled(true);
        jTextFieldTlfno1.setEnabled(true);
        jTextFieldTlfno2.setEnabled(true);
        jTextAreaDireccion.setEnabled(true);
        jTextFieldUsuario.setEnabled(true);
        jPasswordFieldPassword.setEnabled(true);
        //botones
        jButtonBuscar.setEnabled(false);
        jButtonAceptar.setEnabled(true);
    }
//funcion para bloquear campos cuando es Actualizacion

    private void CamposUpdate() {
        //texto
        jTextFieldCedula.setEnabled(false);
        jTextFieldNombres.setEnabled(true);
        jTextFieldApellidos.setEnabled(true);
        jTextFieldTlfno1.setEnabled(true);
        jTextFieldTlfno2.setEnabled(true);
        jTextAreaDireccion.setEnabled(true);
        jTextFieldUsuario.setEnabled(true);
        jPasswordFieldPassword.setEnabled(true);
        //botones
        jButtonBuscar.setEnabled(true);
        jButtonAceptar.setEnabled(false);
    }
//funcion para bloquear campos cuando es Eliminacion

    private void CamposDelete() {
        //texto
        jTextFieldCedula.setEnabled(false);
        jTextFieldNombres.setEnabled(false);
        jTextFieldApellidos.setEnabled(false);
        jTextFieldTlfno1.setEnabled(false);
        jTextFieldTlfno2.setEnabled(false);
        jTextAreaDireccion.setEnabled(false);
        jTextFieldUsuario.setEnabled(false);
        jPasswordFieldPassword.setEnabled(false);
        //botones
        jButtonBuscar.setEnabled(true);
        jButtonAceptar.setEnabled(false);
    }
//funcion que me permite verificar los campos nulos del formulario

    private boolean CamposNulos() {
        boolean band = false;

        if (jTextFieldCedula.getText().trim().equals("")) {
            txtnulos = txtnulos + "CEDULA\n";
            band = true;
        }
        if (jTextFieldNombres.getText().trim().toUpperCase().equals("")) {
            txtnulos = txtnulos + "NOMBRES\n";
            band = true;
        }
        if (jTextFieldApellidos.getText().trim().toUpperCase().equals("")) {
            txtnulos = txtnulos + "APELLIDOS\n";
            band = true;
        }
        if (jTextAreaDireccion.getText().trim().equals("")) {
            txtnulos = txtnulos + "DIRECCION\n";
            band = true;
        }
        if (jTextFieldTlfno1.getText().trim().equals("")) {
            txtnulos = txtnulos + "TELEFONO 1\n";
            band = true;
        }
        if (jTextFieldUsuario.getText().trim().equals("")) {
            txtnulos = txtnulos + "USUARIO\n";
            band = true;
        }
        if (jPasswordFieldPassword.getText().trim().equals("")) {
            txtnulos = txtnulos + "PASSWORD\n";
            band = true;
        }

        return band;
    }
//Set de los datos establecidos para el cliente

    private void DatosFormulario(cEmpleado obj1, cEmpleado_Users obj2) {
//        obj.setNumIDCliente(Integer.parseInt(jTextFieldCodigo.getText().toString()));
        obj1.setTxtCIEmpleado(jTextFieldCedula.getText());
        obj1.setTxtNombre(jTextFieldNombres.getText().toUpperCase());
        obj1.setTxtApellido(jTextFieldApellidos.getText().toUpperCase());
        obj1.setTxtNumTlfno1(jTextFieldTlfno1.getText());
        obj1.setTxtNumTlfno2(jTextFieldTlfno2.getText());
        obj1.setTxtDireccion(jTextAreaDireccion.getText().toUpperCase());
        //para la tabla de credenciales
        obj2.setNumIDEmpleado(Integer.parseInt(jTextFieldCodigo.getText().toString()));
        obj2.setTxtUser(jTextFieldUsuario.getText());
        obj2.setTxtPasswd(jPasswordFieldPassword.getText());
        obj2.setTxtRol(jComboBox1.getSelectedItem().toString());
    }
//Asigno los datos devueltos en una busqueda    

    private void DatosFormularioBusqueda(String obj) throws Exception {
        String[] tupla = new String[10];
        tupla = AD_Empleado.BuscarCI(obj);

        jTextFieldCodigo.setText(tupla[0]);
        jTextFieldCedula.setText(tupla[1]);
        jTextFieldNombres.setText(tupla[2]);
        jTextFieldApellidos.setText(tupla[3]);
        jTextAreaDireccion.setText(tupla[4]);
        jTextFieldTlfno1.setText(tupla[5]);
        jTextFieldTlfno2.setText(tupla[6]);
        //para las credenciales
        tupla = AD_Empleado_Users.BuscarNumID(jTextFieldCodigo.getText().toString());
        jTextFieldUsuario.setText(tupla[1]);
        jPasswordFieldPassword.setText(tupla[2]);
        jComboBox1.setSelectedItem(tupla[3]);
    }

    /**
     * This method is called from within the constructor to initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is always
     * regenerated by the Form Editor.
     */
    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        buttonGroup1 = new javax.swing.ButtonGroup();
        jPanelOpciones = new javax.swing.JPanel();
        jRadioButtonInsert = new javax.swing.JRadioButton();
        jRadioButtonUpdate = new javax.swing.JRadioButton();
        jRadioButtonDelete = new javax.swing.JRadioButton();
        jButtonBuscar = new javax.swing.JButton();
        jTabbedPaneDatos = new javax.swing.JTabbedPane();
        jPanelDatos1 = new javax.swing.JPanel();
        jLabelCodigo = new javax.swing.JLabel();
        jTextFieldCodigo = new javax.swing.JTextField();
        jLabelCI = new javax.swing.JLabel();
        jLabelNombres = new javax.swing.JLabel();
        jLabelApellidos = new javax.swing.JLabel();
        jLabelTlfno1 = new javax.swing.JLabel();
        jLabelDireccion = new javax.swing.JLabel();
        jTextFieldCedula = new javax.swing.JTextField();
        jTextFieldNombres = new javax.swing.JTextField();
        jTextFieldApellidos = new javax.swing.JTextField();
        jTextFieldTlfno1 = new javax.swing.JTextField();
        jScrollPaneDireccion = new javax.swing.JScrollPane();
        jTextAreaDireccion = new javax.swing.JTextArea();
        jLabelEjmTlfno = new javax.swing.JLabel();
        jLabelEjmCI = new javax.swing.JLabel();
        jLabelTlfno2 = new javax.swing.JLabel();
        jTextFieldTlfno2 = new javax.swing.JTextField();
        jPanelDatos2 = new javax.swing.JPanel();
        jLabelNombres1 = new javax.swing.JLabel();
        jTextFieldUsuario = new javax.swing.JTextField();
        jLabelApellidos1 = new javax.swing.JLabel();
        jLabelApellidos2 = new javax.swing.JLabel();
        jComboBox1 = new javax.swing.JComboBox();
        jPasswordFieldPassword = new javax.swing.JPasswordField();
        jPanelBotones = new javax.swing.JPanel();
        jButtonAceptar = new javax.swing.JButton();
        jButtonCancelar = new javax.swing.JButton();

        setDefaultCloseOperation(javax.swing.WindowConstants.DISPOSE_ON_CLOSE);
        setTitle("DATOS DEL EMPLEADO");

        jPanelOpciones.setBorder(javax.swing.BorderFactory.createTitledBorder(null, "OPCIONES DEL EMPLEADO", javax.swing.border.TitledBorder.DEFAULT_JUSTIFICATION, javax.swing.border.TitledBorder.DEFAULT_POSITION, new java.awt.Font("Arial", 1, 18))); // NOI18N

        buttonGroup1.add(jRadioButtonInsert);
        jRadioButtonInsert.setFont(new java.awt.Font("Tahoma", 0, 14)); // NOI18N
        jRadioButtonInsert.setText("AGREGAR");
        jRadioButtonInsert.addMouseListener(new java.awt.event.MouseAdapter() {
            public void mouseClicked(java.awt.event.MouseEvent evt) {
                jRadioButtonInsertMouseClicked(evt);
            }
        });

        buttonGroup1.add(jRadioButtonUpdate);
        jRadioButtonUpdate.setFont(new java.awt.Font("Tahoma", 0, 14)); // NOI18N
        jRadioButtonUpdate.setText("MODIFICAR");
        jRadioButtonUpdate.addMouseListener(new java.awt.event.MouseAdapter() {
            public void mouseClicked(java.awt.event.MouseEvent evt) {
                jRadioButtonUpdateMouseClicked(evt);
            }
        });

        buttonGroup1.add(jRadioButtonDelete);
        jRadioButtonDelete.setFont(new java.awt.Font("Tahoma", 0, 14)); // NOI18N
        jRadioButtonDelete.setText("ELIMINAR");
        jRadioButtonDelete.addMouseListener(new java.awt.event.MouseAdapter() {
            public void mouseClicked(java.awt.event.MouseEvent evt) {
                jRadioButtonDeleteMouseClicked(evt);
            }
        });

        jButtonBuscar.setFont(new java.awt.Font("Tahoma", 0, 14)); // NOI18N
        jButtonBuscar.setIcon(new javax.swing.ImageIcon(getClass().getResource("/Imagenes/16Nuvola_search_person.png"))); // NOI18N
        jButtonBuscar.setText("BUSCAR");
        jButtonBuscar.setEnabled(false);
        jButtonBuscar.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButtonBuscarActionPerformed(evt);
            }
        });

        javax.swing.GroupLayout jPanelOpcionesLayout = new javax.swing.GroupLayout(jPanelOpciones);
        jPanelOpciones.setLayout(jPanelOpcionesLayout);
        jPanelOpcionesLayout.setHorizontalGroup(
            jPanelOpcionesLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanelOpcionesLayout.createSequentialGroup()
                .addContainerGap()
                .addGroup(jPanelOpcionesLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                    .addComponent(jButtonBuscar)
                    .addGroup(jPanelOpcionesLayout.createSequentialGroup()
                        .addComponent(jRadioButtonInsert)
                        .addGap(77, 77, 77)
                        .addComponent(jRadioButtonUpdate)))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                .addComponent(jRadioButtonDelete)
                .addContainerGap())
        );
        jPanelOpcionesLayout.setVerticalGroup(
            jPanelOpcionesLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanelOpcionesLayout.createSequentialGroup()
                .addContainerGap()
                .addGroup(jPanelOpcionesLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jRadioButtonInsert)
                    .addComponent(jRadioButtonUpdate)
                    .addComponent(jRadioButtonDelete))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addComponent(jButtonBuscar)
                .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
        );

        jTabbedPaneDatos.setFont(new java.awt.Font("Tahoma", 0, 14)); // NOI18N

        jPanelDatos1.setFont(new java.awt.Font("Tahoma", 0, 14)); // NOI18N

        jLabelCodigo.setFont(new java.awt.Font("Tahoma", 0, 14)); // NOI18N
        jLabelCodigo.setText("CODIGO:");

        jTextFieldCodigo.setEditable(false);
        jTextFieldCodigo.setFont(new java.awt.Font("Tahoma", 0, 14)); // NOI18N

        jLabelCI.setFont(new java.awt.Font("Tahoma", 0, 14)); // NOI18N
        jLabelCI.setText("CEDULA:");

        jLabelNombres.setFont(new java.awt.Font("Tahoma", 0, 14)); // NOI18N
        jLabelNombres.setText("NOMBRES:");

        jLabelApellidos.setFont(new java.awt.Font("Tahoma", 0, 14)); // NOI18N
        jLabelApellidos.setText("APELLIDOS:");

        jLabelTlfno1.setFont(new java.awt.Font("Tahoma", 0, 14)); // NOI18N
        jLabelTlfno1.setText("TELEFONO 1:");

        jLabelDireccion.setFont(new java.awt.Font("Tahoma", 0, 14)); // NOI18N
        jLabelDireccion.setText("DIRECCION:");

        jTextFieldCedula.setFont(new java.awt.Font("Tahoma", 0, 14)); // NOI18N
        jTextFieldCedula.addKeyListener(new java.awt.event.KeyAdapter() {
            public void keyTyped(java.awt.event.KeyEvent evt) {
                jTextFieldCedulaKeyTyped(evt);
            }
        });

        jTextFieldNombres.setFont(new java.awt.Font("Tahoma", 0, 14)); // NOI18N
        jTextFieldNombres.setCursor(new java.awt.Cursor(java.awt.Cursor.DEFAULT_CURSOR));
        jTextFieldNombres.addKeyListener(new java.awt.event.KeyAdapter() {
            public void keyTyped(java.awt.event.KeyEvent evt) {
                jTextFieldNombresKeyTyped(evt);
            }
        });

        jTextFieldApellidos.setFont(new java.awt.Font("Tahoma", 0, 14)); // NOI18N
        jTextFieldApellidos.addKeyListener(new java.awt.event.KeyAdapter() {
            public void keyTyped(java.awt.event.KeyEvent evt) {
                jTextFieldApellidosKeyTyped(evt);
            }
        });

        jTextFieldTlfno1.setFont(new java.awt.Font("Tahoma", 0, 14)); // NOI18N
        jTextFieldTlfno1.addKeyListener(new java.awt.event.KeyAdapter() {
            public void keyTyped(java.awt.event.KeyEvent evt) {
                jTextFieldTlfno1KeyTyped(evt);
            }
        });

        jTextAreaDireccion.setColumns(20);
        jTextAreaDireccion.setFont(new java.awt.Font("Tahoma", 0, 14)); // NOI18N
        jTextAreaDireccion.setRows(5);
        jScrollPaneDireccion.setViewportView(jTextAreaDireccion);

        jLabelEjmTlfno.setText("Ejm: 095632145");

        jLabelEjmCI.setText("Ejm: 1715632458001");

        jLabelTlfno2.setFont(new java.awt.Font("Tahoma", 0, 14)); // NOI18N
        jLabelTlfno2.setText("TELEFONO 2:");

        jTextFieldTlfno2.setFont(new java.awt.Font("Tahoma", 0, 14)); // NOI18N
        jTextFieldTlfno2.addKeyListener(new java.awt.event.KeyAdapter() {
            public void keyTyped(java.awt.event.KeyEvent evt) {
                jTextFieldTlfno2KeyTyped(evt);
            }
        });

        javax.swing.GroupLayout jPanelDatos1Layout = new javax.swing.GroupLayout(jPanelDatos1);
        jPanelDatos1.setLayout(jPanelDatos1Layout);
        jPanelDatos1Layout.setHorizontalGroup(
            jPanelDatos1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanelDatos1Layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(jPanelDatos1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(jPanelDatos1Layout.createSequentialGroup()
                        .addComponent(jLabelDireccion)
                        .addGap(12, 12, 12)
                        .addGroup(jPanelDatos1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addGroup(jPanelDatos1Layout.createSequentialGroup()
                                .addGap(18, 18, 18)
                                .addGroup(jPanelDatos1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                                    .addGroup(jPanelDatos1Layout.createSequentialGroup()
                                        .addComponent(jTextFieldTlfno1, javax.swing.GroupLayout.PREFERRED_SIZE, 106, javax.swing.GroupLayout.PREFERRED_SIZE)
                                        .addGap(43, 43, 43)
                                        .addComponent(jLabelEjmTlfno))
                                    .addComponent(jTextFieldApellidos, javax.swing.GroupLayout.PREFERRED_SIZE, 293, javax.swing.GroupLayout.PREFERRED_SIZE)
                                    .addComponent(jScrollPaneDireccion, javax.swing.GroupLayout.PREFERRED_SIZE, 293, javax.swing.GroupLayout.PREFERRED_SIZE)
                                    .addComponent(jTextFieldNombres, javax.swing.GroupLayout.PREFERRED_SIZE, 293, javax.swing.GroupLayout.PREFERRED_SIZE)
                                    .addComponent(jTextFieldTlfno2, javax.swing.GroupLayout.PREFERRED_SIZE, 106, javax.swing.GroupLayout.PREFERRED_SIZE)))
                            .addGroup(jPanelDatos1Layout.createSequentialGroup()
                                .addGap(17, 17, 17)
                                .addGroup(jPanelDatos1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                                    .addComponent(jTextFieldCodigo, javax.swing.GroupLayout.PREFERRED_SIZE, 79, javax.swing.GroupLayout.PREFERRED_SIZE)
                                    .addGroup(jPanelDatos1Layout.createSequentialGroup()
                                        .addComponent(jTextFieldCedula, javax.swing.GroupLayout.PREFERRED_SIZE, 124, javax.swing.GroupLayout.PREFERRED_SIZE)
                                        .addGap(30, 30, 30)
                                        .addComponent(jLabelEjmCI))))))
                    .addComponent(jLabelTlfno2)
                    .addComponent(jLabelNombres)
                    .addComponent(jLabelTlfno1)
                    .addComponent(jLabelApellidos)
                    .addComponent(jLabelCI)
                    .addComponent(jLabelCodigo))
                .addContainerGap(21, Short.MAX_VALUE))
        );
        jPanelDatos1Layout.setVerticalGroup(
            jPanelDatos1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanelDatos1Layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(jPanelDatos1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabelCodigo)
                    .addComponent(jTextFieldCodigo, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addGroup(jPanelDatos1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabelCI)
                    .addComponent(jTextFieldCedula, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(jLabelEjmCI))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addGroup(jPanelDatos1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabelNombres)
                    .addComponent(jTextFieldNombres, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addGroup(jPanelDatos1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabelApellidos)
                    .addComponent(jTextFieldApellidos, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addGroup(jPanelDatos1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabelTlfno1)
                    .addComponent(jTextFieldTlfno1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(jLabelEjmTlfno))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addGroup(jPanelDatos1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabelTlfno2)
                    .addComponent(jTextFieldTlfno2, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addGap(18, 18, 18)
                .addGroup(jPanelDatos1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(jLabelDireccion)
                    .addComponent(jScrollPaneDireccion, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addContainerGap(12, Short.MAX_VALUE))
        );

        jTabbedPaneDatos.addTab("DATOS DEL EMPLEADO", jPanelDatos1);

        jLabelNombres1.setFont(new java.awt.Font("Tahoma", 0, 14)); // NOI18N
        jLabelNombres1.setText("USUARIO:");

        jTextFieldUsuario.setFont(new java.awt.Font("Tahoma", 0, 14)); // NOI18N
        jTextFieldUsuario.setCursor(new java.awt.Cursor(java.awt.Cursor.DEFAULT_CURSOR));
        jTextFieldUsuario.addKeyListener(new java.awt.event.KeyAdapter() {
            public void keyTyped(java.awt.event.KeyEvent evt) {
                jTextFieldUsuarioKeyTyped(evt);
            }
        });

        jLabelApellidos1.setFont(new java.awt.Font("Tahoma", 0, 14)); // NOI18N
        jLabelApellidos1.setText("PASSWORD:");

        jLabelApellidos2.setFont(new java.awt.Font("Tahoma", 0, 14)); // NOI18N
        jLabelApellidos2.setText("ROL:");

        jComboBox1.setFont(new java.awt.Font("Tahoma", 0, 14)); // NOI18N
        jComboBox1.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "Ventas", "Administrador" }));

        jPasswordFieldPassword.setFont(new java.awt.Font("Tahoma", 0, 14)); // NOI18N

        javax.swing.GroupLayout jPanelDatos2Layout = new javax.swing.GroupLayout(jPanelDatos2);
        jPanelDatos2.setLayout(jPanelDatos2Layout);
        jPanelDatos2Layout.setHorizontalGroup(
            jPanelDatos2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanelDatos2Layout.createSequentialGroup()
                .addContainerGap(58, Short.MAX_VALUE)
                .addGroup(jPanelDatos2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
                    .addComponent(jLabelNombres1)
                    .addGroup(jPanelDatos2Layout.createSequentialGroup()
                        .addComponent(jLabelApellidos1)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                        .addComponent(jPasswordFieldPassword))
                    .addGroup(jPanelDatos2Layout.createSequentialGroup()
                        .addComponent(jLabelApellidos2)
                        .addGap(58, 58, 58)
                        .addGroup(jPanelDatos2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addComponent(jComboBox1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addComponent(jTextFieldUsuario, javax.swing.GroupLayout.PREFERRED_SIZE, 229, javax.swing.GroupLayout.PREFERRED_SIZE))))
                .addGap(55, 55, 55))
        );
        jPanelDatos2Layout.setVerticalGroup(
            jPanelDatos2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanelDatos2Layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(jPanelDatos2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabelNombres1)
                    .addComponent(jTextFieldUsuario, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addGroup(jPanelDatos2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabelApellidos1)
                    .addComponent(jPasswordFieldPassword, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addGroup(jPanelDatos2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabelApellidos2)
                    .addComponent(jComboBox1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addContainerGap(226, Short.MAX_VALUE))
        );

        jTabbedPaneDatos.addTab("CREDENCIALES", jPanelDatos2);

        jPanelBotones.setBorder(javax.swing.BorderFactory.createEtchedBorder());

        jButtonAceptar.setFont(new java.awt.Font("Tahoma", 0, 14)); // NOI18N
        jButtonAceptar.setIcon(new javax.swing.ImageIcon(getClass().getResource("/Imagenes/16px-Crystal_Clear_action_apply.png"))); // NOI18N
        jButtonAceptar.setText("ACEPTAR");
        jButtonAceptar.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButtonAceptarActionPerformed(evt);
            }
        });

        jButtonCancelar.setFont(new java.awt.Font("Tahoma", 0, 14)); // NOI18N
        jButtonCancelar.setIcon(new javax.swing.ImageIcon(getClass().getResource("/Imagenes/16px-Crystal_Clear_action_button_cancel.png"))); // NOI18N
        jButtonCancelar.setText("CANCELAR");
        jButtonCancelar.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButtonCancelarActionPerformed(evt);
            }
        });

        javax.swing.GroupLayout jPanelBotonesLayout = new javax.swing.GroupLayout(jPanelBotones);
        jPanelBotones.setLayout(jPanelBotonesLayout);
        jPanelBotonesLayout.setHorizontalGroup(
            jPanelBotonesLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanelBotonesLayout.createSequentialGroup()
                .addContainerGap()
                .addComponent(jButtonAceptar)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 54, Short.MAX_VALUE)
                .addComponent(jButtonCancelar)
                .addContainerGap())
        );
        jPanelBotonesLayout.setVerticalGroup(
            jPanelBotonesLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanelBotonesLayout.createSequentialGroup()
                .addContainerGap()
                .addGroup(jPanelBotonesLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jButtonAceptar)
                    .addComponent(jButtonCancelar))
                .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
        );

        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
        getContentPane().setLayout(layout);
        layout.setHorizontalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
                        .addComponent(jTabbedPaneDatos, javax.swing.GroupLayout.PREFERRED_SIZE, 436, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addGroup(layout.createSequentialGroup()
                            .addContainerGap()
                            .addComponent(jPanelOpciones, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)))
                    .addGroup(layout.createSequentialGroup()
                        .addGap(63, 63, 63)
                        .addComponent(jPanelBotones, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)))
                .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
        );
        layout.setVerticalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addContainerGap()
                .addComponent(jPanelOpciones, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addComponent(jTabbedPaneDatos, javax.swing.GroupLayout.PREFERRED_SIZE, 356, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addGap(18, 18, 18)
                .addComponent(jPanelBotones, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
        );

        pack();
    }// </editor-fold>//GEN-END:initComponents

    private void jRadioButtonInsertMouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_jRadioButtonInsertMouseClicked
        // TODO add your handling code here:
        CamposInsert();
        CamposClean();
        int e;
        try {
            e = AD_Empleado.GetId();
            e += 1;
            if (e >= 0) {
                jTextFieldCodigo.setText(Integer.toString(e));
            } else {
                JOptionPane.showMessageDialog(null, "Existe el siguiente error:\n" + e, "ERROR AL OBTENER CODIGO", JOptionPane.ERROR_MESSAGE);
            }
            cConexion.cerrar();
        } catch (Exception ex) {
            Logger.getLogger(Frm_Clientes.class.getName()).log(Level.SEVERE, null, ex);
        }

    }//GEN-LAST:event_jRadioButtonInsertMouseClicked

    private void jRadioButtonUpdateMouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_jRadioButtonUpdateMouseClicked
        // TODO add your handling code here:
        CamposUpdate();
        CamposClean();
    }//GEN-LAST:event_jRadioButtonUpdateMouseClicked

    private void jRadioButtonDeleteMouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_jRadioButtonDeleteMouseClicked
        // TODO add your handling code here:
        CamposDelete();
        CamposClean();
    }//GEN-LAST:event_jRadioButtonDeleteMouseClicked

    private void jButtonBuscarActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButtonBuscarActionPerformed
        // TODO add your handling code here:
        if (jRadioButtonUpdate.isSelected() == true || jRadioButtonDelete.isSelected() == true) {
            String objcadena = "";
            Frm_busq_empleado.setDefaultLookAndFeelDecorated(true);
            Frm_busq_empleado obj;
            try {
                obj = new Frm_busq_empleado(null, true, objcadena);
                obj.setVisible(true);
                if (!obj.getObjcadena().equals("")) {
                    DatosFormularioBusqueda(obj.getObjcadena());
                }
                cConexion.cerrar();
            } catch (Exception ex) {
                Logger.getLogger(Frm_Clientes.class.getName()).log(Level.SEVERE, null, ex);
            }

            //        DatosfrmBusq(obj.getObjcli());
            jButtonAceptar.setEnabled(true);
        }
    }//GEN-LAST:event_jButtonBuscarActionPerformed

    private void jTextFieldCedulaKeyTyped(java.awt.event.KeyEvent evt) {//GEN-FIRST:event_jTextFieldCedulaKeyTyped
        // TODO add your handling code here:
        char t = evt.getKeyChar();
        if (!((t >= '0' && t <= '9')) || jTextFieldCedula.getText().length() > 9) {
            evt.setKeyChar('\b');
        }
    }//GEN-LAST:event_jTextFieldCedulaKeyTyped

    private void jTextFieldNombresKeyTyped(java.awt.event.KeyEvent evt) {//GEN-FIRST:event_jTextFieldNombresKeyTyped
        // TODO add your handling code here:
        char t = evt.getKeyChar();
        if (!((t >= 'A' && t <= 'Z') || (t == ' ') || (t == 'Ñ') || (t == 'é') || (t == 'í') || (t == 'ó') || (t == 'ú') || (t == 'á') || (t == 'ñ') || ((t >= 'a' && t <= 'z'))) || jTextFieldNombres.getText().length() > 50) {
            evt.setKeyChar('\b');
        }
    }//GEN-LAST:event_jTextFieldNombresKeyTyped

    private void jTextFieldApellidosKeyTyped(java.awt.event.KeyEvent evt) {//GEN-FIRST:event_jTextFieldApellidosKeyTyped
        // TODO add your handling code here:
        char t = evt.getKeyChar();
        if (!((t >= 'A' && t <= 'Z') || (t == ' ') || (t == 'Ñ') || (t == 'é') || (t == 'í') || (t == 'ó') || (t == 'ú') || (t == 'á') || (t == 'ñ') || ((t >= 'a' && t <= 'z'))) || jTextFieldApellidos.getText().length() > 50) {
            evt.setKeyChar('\b');
        }
    }//GEN-LAST:event_jTextFieldApellidosKeyTyped

    private void jTextFieldTlfno1KeyTyped(java.awt.event.KeyEvent evt) {//GEN-FIRST:event_jTextFieldTlfno1KeyTyped
        // TODO add your handling code here:
        char t = evt.getKeyChar();
        if (!((t >= '0' && t <= '9')) || jTextFieldTlfno1.getText().length() > 8) {
            evt.setKeyChar('\b');
        }
    }//GEN-LAST:event_jTextFieldTlfno1KeyTyped

    private void jButtonAceptarActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButtonAceptarActionPerformed

        //codigo para realizar las diferentes tareas Insert,Update,Delete
        Exception e;
        if (CamposNulos() == true) {//verifico que campo se encuentra vacio y advierto
            JOptionPane.showMessageDialog(null, txtnulos, "Campos Vacios", JOptionPane.INFORMATION_MESSAGE);
            txtnulos = "Los Campos Vacios son:\n";
        } else {//Inicio la Insercion
            if (jRadioButtonInsert.isSelected() == true) {
                cEmpleado obj1 = new cEmpleado();
                cEmpleado_Users obj2 = new cEmpleado_Users();
                DatosFormulario(obj1, obj2);
                try {
                    e = AD_Empleado.Insertar(obj1, obj2);
                    if (e == null) {
                        JOptionPane.showMessageDialog(null, "El CLIENTE ha sido ingresado correctamente", "INSERTAR", JOptionPane.INFORMATION_MESSAGE);
                    } else {
                        JOptionPane.showMessageDialog(null, "Existe el siguiente error:\n" + e, "ERROR AL INSERTAR", JOptionPane.ERROR_MESSAGE);
                    }
                    dispose();
                    cConexion.cerrar();
                } catch (Exception ex) {
                    Logger.getLogger(Frm_Clientes.class.getName()).log(Level.SEVERE, null, ex);
                }
            }//Terminamos con la Insercion
            else {//Inicio de Actualizacion
                if (jRadioButtonUpdate.isSelected() == true) {
                    cEmpleado obj1 = new cEmpleado();
                    cEmpleado_Users obj2 = new cEmpleado_Users();
                    DatosFormulario(obj1, obj2);
                    try {

                        e = AD_Empleado.Actualizar(obj1,obj2);
                        if (e == null) {
                            JOptionPane.showMessageDialog(null, "Los datos se han actualizado correctamente", "MODIFICAR", JOptionPane.INFORMATION_MESSAGE);
                        } else {
                            JOptionPane.showMessageDialog(null, "Existe el siguiente error:\n" + e, "ERROR AL MODIFICAR", JOptionPane.ERROR_MESSAGE);
                        }
                        dispose();
                        cConexion.cerrar();
                    } catch (Exception ex) {
                        Logger.getLogger(Frm_Clientes.class.getName()).log(Level.SEVERE, null, ex);
                    }
                }//terminanos con la Actualizacion
                else {//Iniciamos la Eliminacion                    
                    try {

                        e = AD_Empleado.Eliminar(jTextFieldCedula.getText());
                        if (e == null) {
                            JOptionPane.showMessageDialog(null, "Los datos se han Eliminado correctamente", "ELIMINAR", JOptionPane.INFORMATION_MESSAGE);
                        } else {
                            JOptionPane.showMessageDialog(null, "Existe el siguiente error:\n" + e, "ERROR AL ELIMINAR", JOptionPane.ERROR_MESSAGE);
                        }
                        dispose();
                        cConexion.cerrar();
                    } catch (Exception ex) {
                        Logger.getLogger(Frm_Clientes.class.getName()).log(Level.SEVERE, null, ex);
                    }
                }//Terminamos la Eliminacion
            }
        }
    }//GEN-LAST:event_jButtonAceptarActionPerformed

    private void jButtonCancelarActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButtonCancelarActionPerformed
        try {
            // TODO add your handling code here:
            dispose();
            cConexion.cerrar();
        } catch (Exception ex) {
            Logger.getLogger(Frm_Clientes.class.getName()).log(Level.SEVERE, null, ex);
        }
    }//GEN-LAST:event_jButtonCancelarActionPerformed

    private void jTextFieldTlfno2KeyTyped(java.awt.event.KeyEvent evt) {//GEN-FIRST:event_jTextFieldTlfno2KeyTyped
        // TODO add your handling code here:
        char t = evt.getKeyChar();
        if (!((t >= '0' && t <= '9')) || jTextFieldTlfno1.getText().length() > 8) {
            evt.setKeyChar('\b');
        }
    }//GEN-LAST:event_jTextFieldTlfno2KeyTyped

    private void jTextFieldUsuarioKeyTyped(java.awt.event.KeyEvent evt) {//GEN-FIRST:event_jTextFieldUsuarioKeyTyped
        // TODO add your handling code here:
    }//GEN-LAST:event_jTextFieldUsuarioKeyTyped

    /**
     * @param args the command line arguments
     */
    public static void main(String args[]) {
        /* Set the Nimbus look and feel */
        //<editor-fold defaultstate="collapsed" desc=" Look and feel setting code (optional) ">
        /* If Nimbus (introduced in Java SE 6) is not available, stay with the default look and feel.
         * For details see http://download.oracle.com/javase/tutorial/uiswing/lookandfeel/plaf.html 
         */
        try {
            for (javax.swing.UIManager.LookAndFeelInfo info : javax.swing.UIManager.getInstalledLookAndFeels()) {
                if ("Nimbus".equals(info.getName())) {
                    javax.swing.UIManager.setLookAndFeel(info.getClassName());
                    break;
                }
            }
        } catch (ClassNotFoundException ex) {
            java.util.logging.Logger.getLogger(Frm_Empleado.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
        } catch (InstantiationException ex) {
            java.util.logging.Logger.getLogger(Frm_Empleado.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
        } catch (IllegalAccessException ex) {
            java.util.logging.Logger.getLogger(Frm_Empleado.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
        } catch (javax.swing.UnsupportedLookAndFeelException ex) {
            java.util.logging.Logger.getLogger(Frm_Empleado.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
        }
        //</editor-fold>

        /* Create and display the form */
        java.awt.EventQueue.invokeLater(new Runnable() {
            public void run() {
                new Frm_Empleado().setVisible(true);
            }
        });
    }
    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.ButtonGroup buttonGroup1;
    private javax.swing.JButton jButtonAceptar;
    private javax.swing.JButton jButtonBuscar;
    private javax.swing.JButton jButtonCancelar;
    private javax.swing.JComboBox jComboBox1;
    private javax.swing.JLabel jLabelApellidos;
    private javax.swing.JLabel jLabelApellidos1;
    private javax.swing.JLabel jLabelApellidos2;
    private javax.swing.JLabel jLabelCI;
    private javax.swing.JLabel jLabelCodigo;
    private javax.swing.JLabel jLabelDireccion;
    private javax.swing.JLabel jLabelEjmCI;
    private javax.swing.JLabel jLabelEjmTlfno;
    private javax.swing.JLabel jLabelNombres;
    private javax.swing.JLabel jLabelNombres1;
    private javax.swing.JLabel jLabelTlfno1;
    private javax.swing.JLabel jLabelTlfno2;
    private javax.swing.JPanel jPanelBotones;
    private javax.swing.JPanel jPanelDatos1;
    private javax.swing.JPanel jPanelDatos2;
    private javax.swing.JPanel jPanelOpciones;
    private javax.swing.JPasswordField jPasswordFieldPassword;
    private javax.swing.JRadioButton jRadioButtonDelete;
    private javax.swing.JRadioButton jRadioButtonInsert;
    private javax.swing.JRadioButton jRadioButtonUpdate;
    private javax.swing.JScrollPane jScrollPaneDireccion;
    private javax.swing.JTabbedPane jTabbedPaneDatos;
    private javax.swing.JTextArea jTextAreaDireccion;
    private javax.swing.JTextField jTextFieldApellidos;
    private javax.swing.JTextField jTextFieldCedula;
    private javax.swing.JTextField jTextFieldCodigo;
    private javax.swing.JTextField jTextFieldNombres;
    private javax.swing.JTextField jTextFieldTlfno1;
    private javax.swing.JTextField jTextFieldTlfno2;
    private javax.swing.JTextField jTextFieldUsuario;
    // End of variables declaration//GEN-END:variables
}
